/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var limite;
var chegou;
 var carregado;

function UR_Start() 
{
        if(carregado == true){
            UR_Nu = new Date();
            UR_Indhold = showFilled(UR_Nu.getMinutes() - chegou) + ":" + showFilled(UR_Nu.getSeconds()); 
                  
            var d = document.getElementById('ur'); 

            if(d != null){
              d.innerHTML = UR_Indhold;
               if(UR_Nu.getMinutes() == limite){
                window.location = 'Game Over.jsp';
                }
            }
        }else{
             carregado = carregarValores();
        }
        setTimeout("UR_Start()",1000);
}

function showFilled(Value) 
{
	return (Value > 9) ? "" + Value : "0" + Value;
}

function carregarValores(){
        var l = document.getElementById("limite");
        var d = document.getElementById("inicio");
        
        if(l != null && d != null){
             chegou = parseInt(d.value);
             limite = parseInt(l.value);
            return true;
        }else{
            return false;
        }
    
}

function init()
{
             carregado = carregarValores();
             
              UR_Start();
}

onload =  init();